package com.e3.basdoc.bank.client;

import java.util.List;

import com.e3.basdoc.bank.model.BankModel;
import com.e3.template.tgf.MyTGFUI;
import com.e3.template.tgf.TGFEditorDialog;
import com.e3.template.tgf.TGFFormPanel;
import com.e3.template.tgf.TGFGridPanel;
import com.e3.template.tgf.TGFQueryDialog;
import com.e3.template.tgf.TGFStateMachine;
import com.e3.template.tgf.TGFTreePanelAsync;
import com.e3.web.core.client.GXTHelper;
import com.e3.web.widget.client.BaseAction;
import com.e3.web.widget.client.MyButton;
import com.google.gwt.user.client.rpc.AsyncCallback;


public class BankUI extends MyTGFUI<BankModel>{
	
	private BankRPCServiceAsync service = BankRPCService.Util.getInstance();
	
	@Override
	protected TGFFormPanel<BankModel> createFormPanel() {
		return new BankFormPanel();
	}

	@Override
	protected TGFGridPanel<BankModel> createGridPanel() {
		return new BankGridPanel();
	}

	@Override
	protected TGFTreePanelAsync<BankModel> createTreePanel() {
		return new BankTreePanel();
	}

	@Override
	protected TGFQueryDialog<BankModel> createQueryDialog() {
		return new BankQueryDialog();
	}

	@Override
	protected TGFEditorDialog<BankModel> createEditorDialog() {
		return new BankEditorDialog();
	}

	@Override
	protected void executeDeleteService(final List<BankModel> models,AsyncCallback<Void> callback) {
		service.deleteBanks(models, callback);
	}

	@Override
	protected String getCurrentLocalName() {
		return BankMessages.INSTANCE.local_name();
	}

	@Override
	protected BankModel createModelInstance() {
		return new BankModel();
	}

	@Override
	protected String getDeletedDetailInfo(List<BankModel> models) {
		String msgs = super.getDeletedDetailInfo(models);
		return msgs+";"+BankMessages.INSTANCE.msg_delete_confirm_notice();
	}

	@Override
	protected BaseAction[] getTreeGridContextMenuActions() {
		if(GXTHelper.isSuperAdmin()){
			return super.getTreeGridContextMenuActions();	
		}
		return new BaseAction[]{TGFStateMachine.NEW_CHILD_ACTION,TGFStateMachine.NEW_ACTION,TGFStateMachine.MODIFY_ACTION};
	}

	@Override
	protected BaseAction[] getToolButtonActions() {
		if(GXTHelper.isSuperAdmin()){
			return super.getToolButtonActions();
		}
		return new BaseAction[]{TGFStateMachine.QUERY_ACTION,TGFStateMachine.NEW_ACTION,TGFStateMachine.MODIFY_ACTION};
	}
	
}
